
package dt.htwk.utilities;

/**
 *	@project:	note2go
 *	@author:	D.Toepel
 *	@version:	2009-08-14
 *	@note:		---
 *	
 *	Copyright (C) 2009  D.Toepel <de.dtools> {at} <gmail> {dot} <com>
 *	
 *	This program is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *	
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *	
 *	You should have received a copy of the GNU General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *	
 */

import java.util.Arrays;
import org.apache.commons.codec.digest.DigestUtils;


public class User {

	private String name;
	private String pword;
	private String email;
	private Integer userid;
	private Boolean isGroup = false;
	
	public User(String name, Integer userid){
		this.name = name;
		this.userid = userid;
	}
	
    public String toString() { return name; }
    public String getName() { return name; }
    public String getEmail() { return email; }
    public Integer getUserID() { return userid; }
    public Boolean isGroup() { return isGroup; }
    public String getPassword() { return pword; }
    
    public void setName(String name){
    	this.name = name;
    }
    
    public void setEmail(String email){
    	this.email = email;
    }
    
    public void setPassword(char[] pword){
    	StringBuilder sb = new StringBuilder();
		for (int i = 0; i < pword.length; i++) {
			sb.append(pword[i]);
		}
		this.pword = DigestUtils.sha256Hex(sb.toString());
		Arrays.fill(pword, '0');
		sb = null;
    }    
    
    public void isGroup(Boolean isGroup){
    	this.isGroup = isGroup;
    }
}
